package jp.co.sapporobeer.FmcDialer.db;

import jp.co.sapporobeer.FmcDialer.DatabaseHelper;
import info.guardianproject.database.sqlcipher.SQLiteDatabase;
import android.content.Context;
import android.provider.SyncStateContract.Helpers;

public class DBManager {
	private static DBManager instance = null;
	private static final String enc_pass = "siGma!11";
	private Context context;
	private DatabaseHelper helper;
	
	private DBManager(Context context){
		this.context = context;
		helper = new DatabaseHelper(context);
		SQLiteDatabase.loadLibs(context);
	}
	
	/*
	public DBManager(Context context){
		this.context = context;
		helper = new DatabaseHelper(context);
		SQLiteDatabase.loadLibs(context);
	}
	*/
	
	public static DBManager getInstance(Context context){
		if(instance == null){
			instance = new DBManager(context);
		}
		return instance;
	}
	
	public SQLiteDatabase getReadableDatabase(){
		//close();
		return helper.getReadableDatabase(enc_pass);
	}
	
	public SQLiteDatabase getWritaDatabase(){
		//close();
		return helper.getWritableDatabase(enc_pass);
	}
	
	public void close(){
		helper.close();
	}
}
